import { request } from './request'

export interface IMenu {
  keyId?: number
  name: string
  path?: string
  status?: number // 1=启用,0=停用
  type?: number // 	菜单类型:1为菜单,2为功能
  children?: IMenu[]
  icon?: string
}

export interface IUpsertRoleMenuParams {
  dataPermission?: string
  id?: number | string
  menuList?: IMenu[]
  roleDesc?: string
  roleName?: string
}

export function getRoleList() {
  return request.post('/role/list')
}

export function upsertRoleMenu(params: IUpsertRoleMenuParams) {
  return request.put('/role/upsertRoleMenu', params)
}

export function getRoleDetail(id: string | number) {
  return request.get(`/role/detail/${id}`)
}

export function deleteRoleById(id: string | number) {
  return request.delete(`/role/delete/${id}`)
}
